package kr.hkit.powerjava.chapter12.interfaceex;

import java.util.*;


public class Histogram {
	int []histogram= new int[10];
	Random rnd=new Random();//랜덤생성
	int [] arr= new int[10];//10개의 배열 생성
	
	//함수만들기(메서드)
	public void getJungso(){//10개의숫자를 받자!
		for (int i = 0; i < arr.length; i++) {
			arr[i]=rnd.nextInt(100)+1;//0포함되어있어서
		}
	}
	
	//함수만들기(분포도)
	public void getHistogram(){
		for (int i = 0; i < arr.length; i++) {
			histogram[(int)(arr[i]-1)/10]++;//분포도에 값을 넣은것
		}
	}
	
	//함수만들기(별생성)
	public void getStar(){
		for (int i = 0; i < histogram.length; i++) {
			System.out.printf("%3d-%3d:",(i*10)+1,(i+1)*10);//1-10,11-20...
			for (int j = 0; j < histogram[i]; j++) {//분포도안에있는것만큼 돌리므로
				System.out.print("*");
				
			}
			System.out.println();
		}
	}
	public static void main(String[] args) {
		Histogram histogram= new Histogram();
		histogram.getJungso();
		histogram.getHistogram();
		histogram.getStar();
	}
}
